<template>
  <el-container class="main">
    <el-header height="20px">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>常见问题</el-breadcrumb-item>
        <el-breadcrumb-item>{{active.title}}</el-breadcrumb-item>
      </el-breadcrumb>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu :default-active="activeIndex + ''" @select="onSelect">
          <el-menu-item v-for="(item, index) of menu" :key="index" :index="index + ''">
            <i :class="item.icon"></i>
            <span slot="title">{{item.title}}</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>

  export default {
    data() {
      return {
        active: undefined,
        menu: [
          { title: '交易纠纷', icon: 'el-icon-warning' },
          { title: '防骗指南', icon: 'el-icon-success' }
        ]
      };
    },
    methods: {
      onSelect(index) {
        this.active = this.menu[index];
      }
    },
    computed: {
      activeIndex() {
        const page = parseInt(this.$route.query.page);
        for (let i = 0; i < this.menu.length; ++i) {
          if (page !== i) continue;
          return i;
        }
        return 0;
      }
    },
    watch: {
      activeIndex(val) {
        this.active = this.menu[val];
      }
    },
    created() {
      this.active = this.menu[0];
    }
  };
</script>
<style lang="scss" type="text/scss" scoped>
.main {
  background: white;
  padding-top: 30px;
  height: 600px;
}
.el-menu {
  height: 100%;
  border: 1px solid $c1;
}
.el-header {
  border-bottom: 2px solid $c1;
  margin-bottom: 10px;
  padding: 0;
}
.el-main {
  margin-left: 10px;
  border: 1px solid $c1;
  li {
    margin-top: 40px;
    color: $c1;
  }
}
.title {
  font-size: 21px;
  font-weight: bold;
  font-family: "微软雅黑","sans-serif";
  text-align: center;
}
.answer {
  border-bottom: 2px solid $c1;
}
.footer {
  margin-top: 60px;
  font-weight: bold;
}
.youshi li {
  color: black;
  margin-top: 30px;
  border-bottom: 2px solid $c1;
}
</style>
